package com.jfok.server.hibernate;

import java.sql.SQLException;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;





@SuppressWarnings("deprecation")
public class testHibernate {

	public static void main(String[] args) throws SQLException {

		Configuration config = new AnnotationConfiguration().configure("/hibernate.cfg.xml");
		config.setInterceptor(new HibernateInterceptor());
		SessionFactory sessionFactory = config.buildSessionFactory();
		Session session = sessionFactory.openSession();
		session.beginTransaction();

//		Criteria criteria = session.createCriteria(AgreementPlanPaymentMonthDetail
//				.class);
//
//		criteria.list();

		// List<_ReportFieldGroup> _ReportGroups =
		// reports.get(0).getReportFieldGroups();
		// for (_ReportFieldGroup g : _ReportGroups){
		// System.out.println(g.getTf_groupName());
		//
		// for (_ReportField f : g.getReportFields()){
		// System.out.println("--" + f.getTf_ModuleField().getTf_title());
		// }
		//
		// }
		// ((_PrintSchemeGroup)criteria.list().get(0)).genHtml();

		// session.createCriteria(_MenuModule.class).list();
		//
		// Query query = session.getNamedQuery("FindModuleFieldWithModuleId");
		// query.setFirstResult(3);
		// query.setMaxResults(1);
		// query.setParameter("tf_moduleId", "9920");
		// List list = query.list();
		// for(Object object : list){
		// System.out.println(object.toString());
		// }
		//
		// Query query1 =
		// session.createQuery("select tf_fieldId , tf_title from _ModuleField");
		// query1.setFirstResult(3);
		// query1.setMaxResults(5);
		// List list1 = query1.list();
		// for(Object object : list1){
		// System.out.println(object.toString());
		// }

		// _MenuGroup group = (_MenuGroup) session.get(_MenuGroup.class, "90");
		// System.out.println(group);
		// group.setTf_menuGroupId("91");
		// session.saveOrUpdate(group);

		// Connection connection = session.connection();
		// Statement stmt = connection.createStatement();
		// stmt.addBatch("update _MenuGroup set tf_menuGroupId = '91' where tf_menuGroupId='90' ");
		// stmt.executeBatch();
		// connection.commit();

		// List<_ModuleAdditionFunction> list =
		// session.createCriteria(_ModuleAdditionFunction.class).list();
		// for (_ModuleAdditionFunction scheme : list)
		// System.out.println(scheme );

		// JSONObject object =
		// JsonToOgnlProcessor.JsonToOgnl(JSONObject.fromObject(list.get(0),
		// JsonDateProcessor.us_jsonConfig));
		// System.out.println(object.toString());
		// session.getTransaction().commit();

	}

	public static Integer aa(Integer bb) {
		bb = bb + 1;
		System.out.println(bb);

		return bb;
	}

}
